home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_xemacs.idb / usr / freeware / lib / xemacs-20.4 / lisp / pcl-cvs / pcl-cvs-xemacs.el.z / pcl-cvs-xemacs.el
Encoding:
Text File  |  1998-05-21  |  4.7 KB  |  138 lines

  1. ;;; Mouse and font support for PCL-CVS 1.3 running in XEmacs
  2. ;; @(#) Id: pcl-cvs-xemacs.el,v 1.2 1993/05/31 19:37:34 ceder Exp 
  3. ;; Copyright (C) 1992-1993 Free Software Foundation, Inc.
  4.  
  5. ;; This file is part of XEmacs.
  6.  
  7. ;; XEmacs is free software; you can redistribute it and/or modify it
  8. ;; under the terms of the GNU General Public License as published by
  9. ;; the Free Software Foundation; either version 2, or (at your option)
  10. ;; any later version.
  11.  
  12. ;; XEmacs is distributed in the hope that it will be useful, but
  13. ;; WITHOUT ANY WARRANTY; without even the implied warranty of
  14. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  15. ;; General Public License for more details.
  16.  
  17. ;; You should have received a copy of the GNU General Public License
  18. ;; along with XEmacs; see the file COPYING.  If not, write to the Free
  19. ;; Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  20.  
  21.  
  22. ;; This simply adds a menu of the common CVS commands to the menubar and to
  23. ;; the right mouse button.  Clicking right moves point, and then pops up a
  24. ;; menu from which commands can be executed.
  25. ;; 
  26. ;; This could stand to be a lot more clever: for example, the "Commit Changes"
  27. ;; command should only be active on files for which there is something to
  28. ;; commit.  Also, some indication of which files the command applies to
  29. ;; (especially in the presence of multiple marked files) would be nice.
  30. ;;
  31. ;; Middle-click runs find-file.
  32.  
  33.  
  34. (require 'pcl-cvs)
  35. ;(load "pcl-cvs.el")
  36.  
  37. (defvar cvs-menu
  38.   '("CVS"
  39.     ["Find File"            cvs-mode-find-file        t]
  40.     ["Find File Other Window"        cvs-mode-find-file-other-window    t]
  41.     ["Interactively Merge (emerge)"    cvs-mode-emerge            t]
  42.     ["Interactively Merge (ediff)"    cvs-mode-ediff            (fboundp 'ediff)]
  43.     ["Diff against Repository"        cvs-mode-diff-cvs        t]
  44.     ["Diff against Backup Version"    cvs-mode-diff-backup        t]
  45.     "----"
  46.     ["Update sources from Repository"    cvs-mode-update-no-prompt    t]
  47.     ["Commit Changes to Repository"    cvs-mode-commit            t]
  48.     ["Revert File from Repository"    cvs-mode-undo-local-changes    t]
  49.     ["Add File to Repository"        cvs-mode-add            t]
  50.     ["Remove File from Repository"    cvs-mode-remove-file        t]
  51.     ["Ignore File"            cvs-mode-ignore            t]
  52.     ["Hide File"            cvs-mode-acknowledge        t]
  53.     ["Hide Handled Files"        cvs-mode-remove-handled        t]
  54.     "----"
  55.     ["Add ChangeLog Entry"    cvs-mode-add-change-log-entry-other-window t]
  56.     ["Show CVS Log"            cvs-mode-log            t]
  57.     ["Show CVS Status"            cvs-mode-status            t]
  58.     "----"
  59.     ["Mark File"            cvs-mode-mark            t]
  60.     ["Unmark File"            cvs-mode-unmark            t]
  61.     ["Mark All Files"            cvs-mode-mark-all-files        t]
  62.     ["Unmark All Files"            cvs-mode-unmark-all-files    t]
  63.     "----"
  64.     ["Quit"                bury-buffer            t]
  65.     ))
  66.  
  67. (defun cvs-menu (e)
  68.   (interactive "e")
  69.   (mouse-set-point e)
  70.   (beginning-of-line)
  71.   (or (looking-at "^[* ] ") (error "No CVS file line here"))
  72.   (popup-menu cvs-menu))
  73.  
  74. (defun cvs-mouse-find-file (e)
  75.   (interactive "e")
  76.   (mouse-set-point e)
  77.   (beginning-of-line)
  78.   (or (looking-at "^[* ] ") (error "No CVS file line here"))
  79.   (cvs-mode-find-file (point)))
  80.  
  81. (define-key cvs-mode-map 'button3 'cvs-menu)
  82. (define-key cvs-mode-map 'button2 'cvs-mouse-find-file)
  83.  
  84. (make-face 'cvs-header-face)
  85. (make-face 'cvs-filename-face)
  86. (make-face 'cvs-status-face)
  87.  
  88. (or (face-differs-from-default-p 'cvs-header-face)
  89.     (copy-face 'italic 'cvs-header-face))
  90.  
  91. (or (face-differs-from-default-p 'cvs-filename-face)
  92.     (copy-face 'bold 'cvs-filename-face))
  93.  
  94. (or (face-differs-from-default-p 'cvs-status-face)
  95.     (copy-face 'bold-italic 'cvs-status-face))
  96.  
  97.  
  98. (defun pcl-mode-motion-highlight-line (event)
  99.   (if (save-excursion
  100.     (let* ((window (event-window event))
  101.            (buffer (and window (event-buffer event)))
  102.            (point (and buffer (event-point event))))
  103.       (and point
  104.            (progn
  105.          (set-buffer buffer)
  106.          (goto-char point)
  107.          (beginning-of-line)
  108.          (looking-at "^[* ] ")))))
  109.       (mode-motion-highlight-line event)))
  110.  
  111. (defconst pcl-cvs-font-lock-keywords
  112.   '(("^In directory \\(.+\\)$" 1 cvs-header-face)
  113.     ("^[* ] \\w+ +\\(ci\\)" 1 cvs-status-face)
  114.     ("^[* ] \\(Conflict\\|Merged\\)" 1 cvs-status-face)
  115.     ("^[* ] \\w+ +\\(ci +\\)?\\(.+\\)$" 2 cvs-filename-face)
  116.     )
  117.   "Patterns to highlight in the *cvs* buffer.")
  118.  
  119. ;;;###autoload
  120. (defun pcl-cvs-fontify ()
  121.   ;;
  122.   ;; set up line highlighting
  123.   (require 'mode-motion)
  124.   (setq mode-motion-hook 'pcl-mode-motion-highlight-line)
  125.   ;;
  126.   ;; set up menubar
  127.   (if (and current-menubar (not (assoc "CVS" current-menubar)))
  128.       (progn
  129.     (set-buffer-menubar (copy-sequence current-menubar))
  130.     (add-menu nil "CVS" (cdr cvs-menu))))
  131.   ;;
  132.   ;; fontify mousable lines
  133.   (set (make-local-variable 'font-lock-keywords) pcl-cvs-font-lock-keywords)
  134.   (font-lock-mode 1)
  135.   )
  136.  
  137. (add-hook 'cvs-mode-hook 'pcl-cvs-fontify)
  138.